<!--
 * @Description: 详情组件
 * @Author: youzi
 * @Date: 2020-05-21 16:07:11
 * @LastEditors: youzi
 * @LastEditTime: 2020-09-30 10:42:53
-->

<template>
  <a-modal
    centered
    :title="initRecord.title"
    closable
    v-model="realVisible"
    :footer="null"
    @cancel="onClose"
    :maskClosable="false"
    :bodyStyle="bodyStyle"
  >
    <div v-html="initRecord.content"></div>
  </a-modal>
</template>
<script>
import modal from '~/tool/modal';
const formItemLayout = {
  labelCol: { span: 6 },
  wrapperCol: { span: 14 }
};
const renderData = [
  {
    inputTitle: '附件',
    dataIndex: 'attachment',
    required: false,
    fileList: []
  }
];
export default {
  name: 'info',
  components: { modal },
  props: {
    apiURL: {
      type: Object,
      default: () => ({})
    },
    visible: {
      default: false
    },
    initRecord: {
      type: Object,
      default: () => {}
    }
  },
  data() {
    return {
      renderData,
      formItemLayout,
      form: this.$form.createForm(this)
    };
  },
  computed: {
    bodyStyle() {
      return {
        maxHeight: window.innerHeight * 0.65 + 'px',
        overflowY: 'scroll',
        padding: '20px'
      };
    },
    realVisible: {
      get() {
        return this.visible;
      },
      set(val) {
        return val;
      }
    },
    // filePreURL: {
    //   get() {
    //     return this.$store.state.setting.filePreURL;
    //   }
    // },
    contractNos() {
      return this.initRecord.contractNos ? this.initRecord.contractNos.split(',') : [];
    }
  },
  methods: {
    // ------------------------------ 界面交互事件 --------------------------------
    // 预览文件函数
    handlePreview(file) {
      // console.warn();
      this.$download(this.apiURL.downloadFile, { id: file.id }, file.fileName + '.' + file.fileType);
    },
    onClose() {
      this.$emit('close');
    }
  }
};
</script>
